package com.eage.security.ienum;

/**
 * @Author: lex
 * @Date: 2019/2/1
 */
public enum ShiroErrorCode {
    CODE_NO_HEAD_TOKEN_ERROR(ShiroJwtCode.NO_HEAD_TOKEN_ERROR, "头部没有token,登入失败"),
    CODE_NO_REDIS_ERROR(ShiroJwtCode.NO_HEAD_TOKEN_ERROR, "该sessionId未在redis中,登入失败"),
    CODE_SYSTEM_ERROR(ShiroJwtCode.NO_HEAD_TOKEN_ERROR, "shiro框架异常,登入失败"),
    CODE_EXPIRE_TIME_ERROR(ShiroJwtCode.EXPIRE_TIME_ERROR, "Token过期,登入失败"),
    CODE_DECODE_ERROR(ShiroJwtCode.DECODE_ERROR, "token验证不通过,登入失败"),
    CODE_NO_SESSIONID_TOKEN_ERROR(ShiroJwtCode.NO_SESSIONID_TOKEN_ERROR, "token中并没有sessionId信息,登入失败");

    private int code;
    private String desc;

    ShiroErrorCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ShiroErrorCode getByCode(int code) {
        for (ShiroErrorCode value : values()) {
            if (value.getCode()==code) {
                return value;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
